New_page!
code:script.js
const outVersion = 'v2.0.0 先頭行が空だった場合、文章が消失する不具合を修正'
const outTitle = '選択範囲を新しいページに切り出す'
console.log(outTitle + ' ' + outVersion)
scrapbox.PopupMenu.addButton({
title: 'New page!',
onClick: text => {
const e = t => encodeURIComponent(t);
const d = t => decodeURIComponent(t);
const lines = text.split(/\r\n/g); let title = '';
if (lines0.length == 0) { const date = new Date();
const ye = date.getFullYear();
const mo = ("0"+(date.getMonth() + 1)).slice(-2);
const da = ("0"+(date.getDate())).slice(-2);
const ho = ("0"+(date.getHours())).slice(-2);
const mi = ("0"+(date.getMinutes())).slice(-2);
const se = ("0"+(date.getSeconds())).slice(-2);
title = ye + mo + da + ho + mi + se;
} else {
.trim()
.replace(/\^\+.icon\]/gm, '')
}
const projectRoot = (() => {
const tmp = location.href.split('/')
tmp.pop()
return tmp.join('/');
})();
const currentPageTitle = d(location.href.split(/\//g).pop());
const body = e(lines.join('\n') + '\n');
window.open(${projectRoot}/${title}?body=${body});
return '';
}
})
更新履歴
v1.0.0 UserScript作成
New pageと異なる点
元ページにリンクを残さない
単行選択でも表示できる
v2.0.0 先頭行が空だった場合、文章が消失する不具合を修正(2020/03/31)